# coding: utf-8
from sqlalchemy import BigInteger, Column, DateTime, Integer, Numeric, Text
from sqlalchemy.schema import FetchedValue
from application import db


# 订单商品字段 下一个订单可能会包含很多个商品
class PayOrderItem(db.Model):
    __tablename__ = 'pay_order_item'

    id = db.Column(db.Integer, primary_key=True)
    #订单id
    pay_order_id = db.Column(db.Integer, nullable=False, index=True, server_default=db.FetchedValue())
    #会员id
    member_id = db.Column(db.BigInteger, nullable=False, server_default=db.FetchedValue())
    # 购买数量
    quantity = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    # 商品总价格，售价 *  数量
    price = db.Column(db.Numeric(10, 2), nullable=False, server_default=db.FetchedValue())
    # 美食表id
    food_id = db.Column(db.Integer, nullable=False, index=True, server_default=db.FetchedValue())
    # 备注信息
    note = db.Column(db.Text, nullable=False)
    #状态值 1 成功 0 失败
    status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
    # 最近一次更新时间
    updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
    # 插入时间
    created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
